import { defHttp } from '@/utils/http/axios';
import { GetCertificateListParams, CreateCertificateParams, CertificateModel } from './model/certificate';

import { ErrorMessageMode } from '#/axios';

export function getCertificateList(params: GetCertificateListParams, mode: ErrorMessageMode = 'message') {
  return defHttp.get<CertificateModel>(
    {
      url: '/organization/certificates',
      params,
    },
    {
      errorMessageMode: mode
    }
  );
}

export function createCertificate(params: CreateCertificateParams, mode: ErrorMessageMode = 'message') {
  return defHttp.post<CertificateModel>(
    {
      url: '/organization/certificates',
      params
    },
    {
      errorMessageMode: mode,
      successMessageMode: mode,
    }
  );
}

export function cancelCertificate(id: number|string, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    {
      url: `/organization/certificates/${id}/cancel`,
    },
    {
      errorMessageMode: mode,
      successMessageMode: mode,
    }
  );
}
